const path = require('path')
const config = require('./config.js')
const app = config.persional?config.wx.appname:config.wx.wmpname+'_'+config.wx.appname
const merge = require('webpack-merge')
const webpackBaseConfig = require('./webpack.base.config.js')
const webpack = require('webpack')
module.exports = merge(webpackBaseConfig, {
    output: {
        filename: '[hash].[name].js',
        path: path.resolve(__dirname, 'dist', app),
        publicPath: '/',
        chunkFilename: '[chunkhash].js'
    },
    plugins:[
        new webpack.HotModuleReplacementPlugin(),
    ],
    devtool: '#eval-source-map',
    devServer: {
        contentBase: path.join(__dirname, 'dist', app),
        compress: true,
        port: 9888,
        hot: true
    },
    module: {
        rules: [
            {
                test: require.resolve('snapsvg/dist/snap.svg.js'),
                use: 'imports-loader?this=>window,fix=>module.exports=0',
            },
        ],
    },
    resolve: {
        alias: {
            snapsvg: 'snapsvg/dist/snap.svg.js',
        },
    }
})